import * as THREE from "three";

// 画长方形
export function createRect({ size }) {
    // TODO instance加速

    const geometry = new THREE.PlaneGeometry(size[0], size[1]);
    const material = new THREE.MeshBasicMaterial({
        color: 0xffff00,
        // side: THREE.DoubleSide,
    });
    let geom = new THREE.Mesh(geometry, material);
    // 默认为XY平面
    geom.rotateY(Math.PI * 0.5) // 旋转到YZ平面
    geom.position.set(0, -size[1] * 0.5, -size[0] * 0.5) // 左上角为原点

    let obj = new THREE.Object3D()
    obj.add(geom)

    // // 坐标轴DEBUG
    // const axesHelper = new THREE.AxesHelper(0.1);
    // obj.add(axesHelper);

    return obj
}
